{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading cn-startup.xml... done (0.01 seconds)\n",
      "Loading cn-test.aiml... done (0.00 seconds)\n",
      "> 你好\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: No match found for input: ���\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "> HELOO\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: No match found for input: HELOO\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "> HELLO\n",
      "HI\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.insert(0, \"../\")\n",
    "\n",
    "import aiml\n",
    "\n",
    "# The Kernel object is the public interface to\n",
    "# the AIML interpreter.\n",
    "k = aiml.Kernel()\n",
    "\n",
    "# Use the 'learn' method to load the contents\n",
    "# of an AIML file into the Kernel.\n",
    "k.learn(\"cn-startup.xml\")\n",
    "\n",
    "# Use the 'respond' method to compute the response\n",
    "# to a user's input string.  respond() returns\n",
    "# the interpreter's response, which in this case\n",
    "# we ignore.\n",
    "k.respond(\"load aiml cn\")\n",
    "\n",
    "# Loop forever, reading user input from the command\n",
    "# line and printing responses.\n",
    "while True: print k.respond(raw_input(\"> \"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
